package cn.xfdzx.android.apps.shop.adapter.remake;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.activity.remake.BigImageViewActivity;
import cn.xfdzx.android.apps.shop.util.ImageGlideUtil;

/**
 * Creator: zf.
 * Date: 2020/9/15.
 * Description:零售我的评价-图片列表适配器.
 */
public class OrderMyRemake_RetailImageListAdapter extends BaseQuickAdapter<String, BaseViewHolder>  {
    private List<String> imgList = new ArrayList<>();//
    public OrderMyRemake_RetailImageListAdapter(@Nullable List<String> data) {
        super(R.layout.item_myremake_imgs, data);
        this.imgList = data;
    }

    @Override
    public void setData(int index, @NonNull String data) {
        super.setData(index, data);
    }


    @Override
    protected void convert(final BaseViewHolder viewHolder, final String date) {

        ImageView imageView = viewHolder.getView(R.id.iv_picture);
        ImageGlideUtil.loadImage(mContext,imageView,date);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, BigImageViewActivity.class);
                intent.putStringArrayListExtra("imgs",(ArrayList<String>)imgList);
                intent.putExtra("position",viewHolder.getLayoutPosition());
                mContext.startActivity(intent);
            }
        });

    }
    public void clearDatas(){
        mData.clear();
        notifyDataSetChanged();
    }
    public void refreshDatas(List<String> list){
        this.imgList = list;
        super.replaceData(list);
    }

}
